#!/usr/bin/env node

const Koa    = require('koa'),
      Router = require('koa-router');
      log    = console.log;

let app    = new Koa(),
    router = new Router();

router.get('/api/tasks/', async (ctx,next)=>{//router中可以不写next
    log('得到代办事项列表');
    ctx.body = '查询成功';
});

router.post('/api/tasks/', async (ctx,next)=>{
    log('提交代办事项');
    ctx.body = '添加成功';
});
  
router.put('/api/tasks/:id', async (ctx,next)=>{
    log('修改代办事项');
    ctx.body = '修改成功';
});

router.delete('/api/tasks/:id',async (ctx,next)=>{
    log('删除代办事项');
    ctx.body = '删除成功';
});

app.use(router.routes());//将路由器加载到中间件中

app.listen(8080);


